package com.ruoyi.jhc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jhc.domain.JhcJh;
import com.ruoyi.jhc.service.IJhcJhService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 能源公司进耗存录入Controller
 * 
 * @author key
 * @date 2022-09-29
 */
@RestController
@RequestMapping("/jhc/jh")
public class JhcJhController extends BaseController
{
    @Autowired
    private IJhcJhService jhcJhService;

    /**
     * 查询能源公司进耗存录入列表
     */
    @PreAuthorize("@ss.hasPermi('jhc:jh:list')")
    @GetMapping("/list")
    public TableDataInfo list(JhcJh jhcJh)
    {
        startPage();
        List<JhcJh> list = jhcJhService.selectJhcJhList(jhcJh);
        return getDataTable(list);
    }

    /**
     * 导出能源公司进耗存录入列表
     */
    @PreAuthorize("@ss.hasPermi('jhc:jh:export')")
    @Log(title = "能源公司进耗存录入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JhcJh jhcJh)
    {
        List<JhcJh> list = jhcJhService.selectJhcJhList(jhcJh);
        ExcelUtil<JhcJh> util = new ExcelUtil<JhcJh>(JhcJh.class);
        util.exportExcel(response, list, "能源公司进耗存录入数据");
    }

    /**
     * 获取能源公司进耗存录入详细信息
     */
    @PreAuthorize("@ss.hasPermi('jhc:jh:query')")
    @GetMapping(value = "/{cDate}")
    public AjaxResult getInfo(@PathVariable("cDate") String cDate)
    {
        return AjaxResult.success(jhcJhService.selectJhcJhByCDate(cDate));
    }

    /**
     * 新增能源公司进耗存录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:jh:add')")
    @Log(title = "能源公司进耗存录入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JhcJh jhcJh)
    {
        return toAjax(jhcJhService.insertJhcJh(jhcJh));
    }

    /**
     * 修改能源公司进耗存录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:jh:edit')")
    @Log(title = "能源公司进耗存录入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JhcJh jhcJh)
    {
        return toAjax(jhcJhService.updateJhcJh(jhcJh));
    }

    /**
     * 删除能源公司进耗存录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:jh:remove')")
    @Log(title = "能源公司进耗存录入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cDates}")
    public AjaxResult remove(@PathVariable String[] cDates)
    {
        return toAjax(jhcJhService.deleteJhcJhByCDates(cDates));
    }
}
